﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using RN.ERP.BLL;
using RN.ERP.DTO;
using System.Web.Services;
using Newtonsoft.Json;

namespace RN.ERP.Web.Material.MaterialProperty
{
    public partial class MPList : System.Web.UI.Page
    {
        MaterialBLL bll = new MaterialBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {
            hdnPid.Value = Request.QueryString["id"];

        }

        protected void RadGridList_ItemCommand(object sender, GridCommandEventArgs e)
        {

        }

        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            BindData();
        }

        private void BindData()
        {
            int pid = 0;
            int.TryParse(hdnPid.Value.Trim(), out pid);
            RadGridList.AllowCustomPaging = true;
            int pageCount = RadGridList.CurrentPageIndex;
            int pageSize = RadGridList.PageSize;
            int count = 0;
            List<DTO.MPInfo> properties = bll.GetMPListByPropertyId(
                pid,
                pageCount,
                pageSize,
                out count);
            RadGridList.VirtualItemCount = count;
            RadGridList.DataSource = properties;
        }

        public string GetInputType(object mPIKind)
        {
            int iMPIKind = 0;
            if (mPIKind == null)
            {
                return string.Empty;
            }
            int.TryParse(mPIKind.ToString(), out iMPIKind);
            switch (iMPIKind)
            {
                case 1:
                    return "单选";
                case 2:
                    return "多选";
                case 3:
                    return "手工录入";
                case 4:
                    return "多行文本框";
                default:
                    return string.Empty;
            }
        }
    }
}